package metier;

import java.sql.ResultSet;
import java.sql.SQLException;

import mappage.CL_mp_artiste;


public class CL_artiste {

	private CL_mp_artiste artiste;
	private ResultSet rs;
	
	public String[] M_charger_artistes(String id){
		artiste = new CL_mp_artiste();
		rs = artiste.M_mp_charger_artistes(id);
		int a = 0;
		int taille = 0;
		String nom;
		try {
			rs.last();
			taille = rs.getRow();
			rs.beforeFirst();
		} catch (SQLException e1) {
			e1.printStackTrace();
		}
		if(taille != 0){
			try {
				String[] data = new String[taille];
				
				while(rs.next())
				{
					data[a] = (rs.getString("nom")+" "+ rs.getString("prenom"));
					a++;
				}
				return data;
			} 
			catch (SQLException e) {
				e.printStackTrace();
			}
		}
		String[] data = new String[1];	
		data[0] = "Aucun artiste";
		return data;
	}

	public int m_Ajouter_Artiste(String nom, String prenom)
	{
		artiste = new CL_mp_artiste();		
		
		int id_artiste = artiste.M_add_artiste(nom,prenom);		
		System.out.println(id_artiste);
		return id_artiste;
		
	}

}
